package com.huanrong.filter;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.huanrong.service.UserService;

import net.sf.json.JSONArray;

@Component
public class TestFilter implements Filter
{
    private static final Logger logger = LogManager.getLogger(TestFilter.class);
    
    @Autowired
    private UserService userService;
    
    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain)
        throws ServletException, IOException
    {
       // logger.info(JSONArray.fromObject(userService.list()));
        filterChain.doFilter(request, response);
    }
    
    @Override
    public void init(FilterConfig filterConfig)
        throws ServletException
    {
        logger.info("初始化filter");
    }
    
    @Override
    public void destroy()
    {
        logger.info("destroyfilter");
    }
}
